package com.seckill.service;

import com.seckill.config.RabbitMQTopicConfig;
import com.seckill.pojo.UserDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: 胡成
 * @Version: 0.0.1V
 * @Date: 2018/12/7
 * @Description: 类描述
 **/
@Slf4j
@Service
public class ReceiverTopicService {

    @Autowired
    private AmqpTemplate amqpTemplate;

    public void sendTopic(){
        UserDTO userDTO1 = new UserDTO();
        userDTO1.setName("zhangsan");
        userDTO1.setUserId("10000");

        UserDTO userDTO2 = new UserDTO();
        userDTO2.setUserId("10001");
        userDTO2.setName("lisi");

        log.info("【sendTopic已发送消息】");
        //第一个参数：TopicExchange名字
        //第二个参数：Route-key
        //第三个参数：要发送的内容
//        amqpTemplate.convertAndSend(RabbitMQTopicConfig.TOPIC_EXCHANGE,"lzc.message",userDTO1);
        amqpTemplate.convertAndSend(RabbitMQTopicConfig.TOPIC_EXCHANGE,"lzc.lzc",userDTO2);
    }
}
